package com.siysoft.tc.admin.action;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.siysoft.tc.admin.service.IAdminMessageService;
import com.siysoft.tc.remind.service.IRemindService;
import com.siysoft.util.IMap;

/**
 * <p>Title: AdminMessageController</p>
 * <p>Description:咨询管理功能</p>
 * <p>Company: dmpb</p>
 * @author    victor
 * @date       2015年11月12日
 */
@Controller
@RequestMapping(value = "/admin/message")
public class AdminMessageController {
	@Autowired
	IAdminMessageService messageService;
	
	@Autowired
	IRemindService remindService;
	
	
	//文章管理
	@RequestMapping(value = "/toMessage")
	public String toMessage(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,Object>> seekMessages = messageService.seekMessages(iMap);
		request.setAttribute("messageList", seekMessages);
		return "/admin/message/messageList";
	}
	//文章管理
	@RequestMapping(value = "/toUserMessage")
	public String toUserMessage(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		List<Map<String,Object>> seekUserMessages = messageService.seekUserMessages(iMap);
		request.setAttribute("userMessageList", seekUserMessages);
		return "/admin/message/userMessageList";
	}
	
	//跳转添加系统消息页面
	@RequestMapping(value = "/addMessage")
	public String addInterest(HttpServletRequest request) throws Exception{
		IMap iMap = new IMap(request);
		messageService.addMessage(iMap);
		remindService.addNewRemind(1,0,0);
		return "redirect:/admin/message/toMessage.htm";
	}
	
	//跳转添加系统消息页面
	@RequestMapping(value = "/toAddMessage")
	public String toAddMessage(HttpServletRequest request) throws Exception{
		return "/admin/message/addMessage";
	}
	
}
